<?php
namespace App\Http\Controllers\Base;

use App\Http\Query\CategoryQuery;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Log;
use SplFileObject;

class BaseController extends Controller

{

    static public function showReturnCode($code = '', $data = [], $msg = '')
    {
        $return_data = [
            'code' => '500',
            'msg' => '未定义消息',
            'data' => $code == 1001 ? $data : [],
        ];
        if (empty($code)) return $return_data;
        $return_data['code'] = $code;
        if(!empty($msg)){
            $return_data['msg'] = $msg;
        }else if (isset(ReturnCode::$return_code[$code]) ) {
            $return_data['msg'] = ReturnCode::$return_code[$code];
        }
        return $return_data;
    }

    public function getDbOne(Request $request)
    {
        $data = $request->all();
        $table = $data['table'];
        if (empty($table)) {
            return self::showReturnCode(1003);
        }
        $list = DB::table($table)->get();
        return self::showReturnCode(1001,$list);

    }

    public function test(Request $request){
        $mo = new \App\Model\Base();
        $list = $mo::goods();
        $w = trans('symessages.goods_size');
        dump($w);
    }



}
